/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package com.minierp.controller;

import com.minierp.dao.MakeRequireDao;
import com.minierp.err.PermissionDennyException;
import com.minierp.helper.EncCommonHelper;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class MakeRequireMACtr extends MultiActionController {
	private MakeRequireDao makeRequireDao;
	private String listView;
	private String listForSelectView;
	private String operateSuccessView;

	public ModelAndView handleList(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "MAKE_REQU")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			ModelAndView mv = new ModelAndView(this.listView);
			List list = this.makeRequireDao.getList("");
			mv.addObject("makeRequireList", list);
			return mv;
		}
	}

	public ModelAndView handleDelete(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.operateSuccessView);
		this.makeRequireDao.delete(Long.parseLong(request.getParameter("id")));
		EncCommonHelper.setAlertMessage(request, "删除成功！");
		return mv;
	}

	public ModelAndView handleListForSelect(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.listForSelectView);
		String searchKey = request.getParameter("search_key");
		List list = this.makeRequireDao.getList(searchKey);
		mv.addObject("makeRequireList", list);
		mv.addObject("searchKey", searchKey);
		return mv;
	}

	public String getListView() {
		return this.listView;
	}

	public void setListView(String listView) {
		this.listView = listView;
	}

	public MakeRequireDao getMakeRequireDao() {
		return this.makeRequireDao;
	}

	public void setMakeRequireDao(MakeRequireDao makeRequireDao) {
		this.makeRequireDao = makeRequireDao;
	}

	public String getOperateSuccessView() {
		return this.operateSuccessView;
	}

	public void setOperateSuccessView(String operateSuccessView) {
		this.operateSuccessView = operateSuccessView;
	}

	public String getListForSelectView() {
		return this.listForSelectView;
	}

	public void setListForSelectView(String listForSelectView) {
		this.listForSelectView = listForSelectView;
	}
}